package com.qbw.app.module.vehicle.holder;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.lib.util.ToastUtil;
import com.qbw.app.R;
import com.qbw.app.databinding.VehicleHolderWarningBinding;
import com.qbw.app.model.Warning;
import com.qbw.app.module.common.holder.CommonHolder;
import com.qbw.app.module.vehicle.activity.VehicleWarningDetailActivity;
import com.qbw.core.base.BaseHolder;

/**
 * @author QBW
 * @date 2019-09-02
 */
public class VehicleWarningHolder extends CommonHolder<Warning, VehicleHolderWarningBinding> {

    public VehicleWarningHolder(Context context, ViewGroup viewParent) {
        super(context, R.layout.vehicle_holder_warning, viewParent);
    }

    @Override
    public void bindData(int position, Warning data) {
        super.bindData(position, data);
        mBinding.setWarning(data);
        mBinding.executePendingBindings();
        itemView.setOnClickListener(mClickListenerItem);
        if(data.getAlarmState() == 0){
//            mBinding.tvNotLocation.setVisibility(View.VISIBLE);
            mBinding.tvContent.setText(data.getAlarmName()+"  "+mContext.getResources().getString(R.string.vehicle_not_loaction));
        }else{
//            mBinding.tvNotLocation.setVisibility(View.GONE);
            mBinding.tvContent.setText(data.getAlarmName());

        }
    }

    @Override
    protected void onClickItem() {
        super.onClickItem();
        if(mData.getAlarmState() == 0){
//            ToastUtil.showToast(mContext,R.string.vehicle_travel_not_loaction_info);
        }else{
            VehicleWarningDetailActivity.start(mContext, mData);
        }

    }
}
